package utils

import (
	"fmt"
	jsoniter "github.com/json-iterator/go"
)

func UnMarshal(data interface{})(map[string]interface{}, error){
	var (
		result map[string]interface{}
		baseText,
		finalText string
		err error
	)
	switch data.(type) {
	case []byte:
		baseText = string(data.([]byte))
	case string:
		baseText = data.(string)
	default:
		err = fmt.Errorf("不支持的反序列化类型")
		return nil,err
	}
	finalText = `{"unmarshalData" : ` + baseText + `}`
	if err = jsoniter.UnmarshalFromString(finalText,&result);err != nil{
		return nil,err
	}else{
		return result,nil
	}
}